#!/bin/bash 
source /etc/profile 
apk_ftp_path=$1
echo user input path=$apk_ftp_path
curl -u aolingli:ALL1234! $apk_ftp_path > apk_path_info
grep -rn ".apk$" apk_path_info |awk -F " " '{print $4}' > apk_path_info.tmp 
mv apk_path_info.tmp apk_path_info
echo will sign as follow:
cat apk_path_info 
sign_path="/usr/local/scripts/build_scripts/sign_apk_tool" 
sign_time=`date "+%Y%m%d%H%M"`
for ftp_apk_name in `cat apk_path_info` 
    do 
        curl -u aolingli:ALL1234! -o $ftp_apk_name  $apk_ftp_path
        if [ -f $ftp_apk_name ];then 
            echo download $ftp_apk_name success
            apk_name=`echo $ftp_apk_name |awk -F ".apk" '{print $1}'`
            echo ================================apktool decompile===========================
            java -jar $sign_path/apktool.jar  d $ftp_apk_name
            echo delete $ftp_apk_name ...
            rm $ftp_apk_name 
            echo ==============================delete META-INF ===================
            rm -rf $apk_name/original/META-INF 
            echo ================================apktool compile============================
            java -jar $sign_path/apktool.jar b $apk_name
            mv $apk_name/dist/$ftp_apk_name ./ 
           
            echo  ===============signning $ftp_apk_name=============
            signed_apk="$sign_time"_signed_$ftp_apk_name
            jarsigner -verbose -digestalg SHA1 -sigalg SHA1withRSA -keystore $sign_path/mirrorcast_aw.key -signedjar $signed_apk $ftp_apk_name mirrorcast_aw -storepass mirrorcastisgood
            echo =============checking signed $signed_apk===============
            jarsigner -certs -verify $signed_apk
            curl -u aolingli:ALL1234! -T $signed_apk  $apk_ftp_path
        else
            echo download $ftp_apk_name failed,
            continue
        fi
    done 
echo ftp_path=$1
